home *** CD-ROM | disk | FTP | other *** search
- // SaveSym.d
- // Saves symbols from a drawing into a designated symbol library
- // Select New Library from the list of symbol libraries if you wish to create a new library from the symbols
- // in the drawing.
-
-
-
- HANDLE hChan; // handle to symbol list
- HANDLE hChanlib; // handle to the symbol library directory
- HANDLE hDlg; // handle for dialog box
- MSGID Ok; // return code from dialog box
- STRING sSymbol; // symbol name
- STRING sSymlib; // library name
- STRING sMessage; // list of symbol libraries
- STRING sLibname; // name of library returned from dialog box
- STRING sNewlib; // name of new symbol library
- STRING sPath; // current SLB directory
- NUMBER nSymbol;
- NUMBER nCount;
- XY xySymList;
-
- Display("message", "error", "If the current drawing doesn't have symbols this won't work!");
-
- GetData("PathSymbol", &sPath);
- Print("the path for symbols is : ", sPath,"\n");
-
- hChanlib = Open("directory", sPath+"\\*.slb", "normal");
- if (hChanlib)
- {
- while(GetNextFile(hChanlib, &sSymlib))
- {
- Print("Existing Symbol Library names are: ", sSymlib, "\n");
- sMessage= sMessage + sSymlib + "\n";
- }
- Close("directory", hChanlib);
-
- }
-
- sMessage=sMessage+"NEW LIBRARY\n";
- Print(sMessage, "\n");
- // create a dialog box for selecting a symbol library
- hDlg = Open("dialog", "Select the desired Symbol Library to use!", "font Arial 10", 20, 20, 194, 40);
- AddControl(hDlg, "defaultbuttion", 140, 2, 50, 14, "OK", "%ok", "");
- AddControl(hDlg, "pushbutton", 140, 20, 50, 14, "Cancel", "%cancel", "");
- AddControl(hDlg, "rtext", 8, 18, 40, 8, "Symbol Libraries:", "", "");
- AddControl(hDlg, "dropdownlistbox", 52, 18, 80, 86, sMessage, "string", "sLibname" );
-
- // displays dialog box.
- Ok=Display("dialog", hDlg, "%center");
- Close("dialog", hDlg);
- if (Ok!=%ok)
- Exit(%cancel, "Aborting Macro as requested!");
-
- Display("message", "error", "The existing symbol library you have selected is: " + sLibname);
-
- if (StringCompare("NEW LIBRARY",sLibname))
- {
- if (GetUser("string", "Please Type in the name of the desired new symbol library!", &sNewlib) != %ok)
- Exit(%cancel, "Aborting Macro as requested!");
- if (SetSymbolLibrary(sNewlib)!=%true)
- Exit(%cancel, "Aborting Macro as requested!");
-
- }
- else
- SetSymbolLibrary(sLibname);
-
-
-
- // Adds the symbols in the current or active drawing to the designated symbol library
- nSymbol = 0;
-
- //open up symbol list
- hChan = Open("symlist", "*");
- if (hChan)
- {
- // get symbol name one at a time
- while (GetNextSymbol(hChan, &sSymbol))
- {
- nSymbol = nSymbol+1;
- Export("symbol", sSymbol);
-
- }
- Close("symlist", hChan);
- }